package com.dragon.backstage.domain.param.role;

import com.dragon.common.domain.param.PaginationParam;
import com.dragon.common.utils.AjaxResult;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.Objects;

/**
 * 角色模块-授权用户搜索请求参数
 *
 * @author dragon
 * @version 1.0
 * @date 2024/8/7 17:16
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Schema(title = "角色模块-授权用户搜索请求参数")
public class RoleAuthUserParam extends PaginationParam {

    /**
     * 角色ID
     */
    @Schema(title = "角色ID", requiredMode = Schema.RequiredMode.REQUIRED)
    private Long roleId;

    /**
     * 用户账号
     */
    @Schema(title = "用户账号")
    private String account;

    /**
     * 手机号码
     */
    @Schema(title = "手机号码")
    private String phoneNumber;

    /**
     * 参数校验
     */
    public static AjaxResult<Void> check(RoleAuthUserParam param) {
        if (Objects.isNull(param)) {
            return AjaxResult.failed("请求参数不能为空");
        }
        if (Objects.isNull(param.getRoleId()) || param.getRoleId().equals(0L)) {
            return AjaxResult.failed("角色ID不能为空");
        }

        return AjaxResult.succeed();
    }

}
